package cn.openea.perpartner.common.auth.util;


import cn.openea.perpartner.common.auth.entity.LoginBody;

/**
 * @author Administrator
 */
public class SessionUtil {

    public static String makeSessionId(LoginBody user) {
        return user.getUserid().concat("_").concat(user.getVersion());
    }

    public static String parseStoreKey(String sessionId) {
        if (sessionId != null && sessionId.contains("_")) {
            return sessionId.substring(0,sessionId.lastIndexOf("_"));
        }
        return null;
    }

    public static String parseVersion(String sessionId) {
        if (sessionId != null && sessionId.contains("_")) {
            return sessionId.substring(sessionId.lastIndexOf("_")+1);
        }
        return null;
    }
}
